package mn.more.wits.client.gui;

import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.*;
import net.mygwt.ui.client.MyDOM;
import net.mygwt.ui.client.event.BaseEvent;
import net.mygwt.ui.client.event.SelectionListener;
import net.mygwt.ui.client.widget.Button;

/** User: nasanjargal */
public class WitsButton extends Button {

	public WitsButton(String s, SelectionListener selectionListener) {
		super(s, selectionListener);
	}

	public WitsButton(String s) {
		super(s);
	}

	protected void onRender() {
		super.onRender();
		MyDOM.addEventsSunk(getElement(), Event.KEYEVENTS);
	}

	public void onBaseEvent(BaseEvent be) {
		super.onBaseEvent(be);
		if (be.type == Event.ONKEYUP) {
			int key = be.getKeyCode();
			if (key == KeyboardListener.KEY_ENTER) {
				onClick(be);
			}
		}
	}
}
